package com.uab.ia.adapters;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.uab.ia.entidades.Estacion;

public class SpinnerEstacionesAdapter extends BaseAdapter {

	private Context ctx;
	private ArrayList<Estacion> objects;

	public SpinnerEstacionesAdapter(Context ctx, ArrayList<Estacion> objects) {
		this.ctx = ctx;
		this.objects = objects;
	}

	public int getCount() {

		return objects.size();
	}

	public Estacion getItem(int position) {
		return objects.get(position);
	}

	public long getItemId(int position) {
		return objects.get(position).getId();
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		
		LayoutInflater inflater = LayoutInflater.from(ctx);
		
		convertView = (TextView) inflater.inflate(android.R.layout.simple_spinner_item, null);
		
		((TextView) convertView).setPadding(5, 10, 5, 10);
		
		((TextView) convertView).setText(objects.get(position).getNombre());
		
		return convertView;
	}

	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		return getView(position, convertView, parent);
	}
}
